#include "ExchangeRepoInfo.h"


CExchangeRepoInfo::CExchangeRepoInfo(){
}

CExchangeRepoInfo::~CExchangeRepoInfo(){
	Clear();
}

void CExchangeRepoInfo::Clear( ){
	std::lock_guard<std::mutex> locker(m_mutex);
	m_map.clear();
}

void CExchangeRepoInfo::Add(CExchangeRepoUnit& one){
	std::lock_guard<std::mutex> locker(m_mutex);
	if(strlen(one.ID) <= 0)return;
	m_map[one.ID] = one;
}

int CExchangeRepoInfo::GetSize(){
	std::lock_guard<std::mutex> locker(m_mutex);
	return (int)m_map.size();
}

CExchangeRepoInfo& CExchangeRepoInfo::instance()
{
	static CExchangeRepoInfo s_cri;
	return s_cri;
}

const CExchangeRepoUnit* CExchangeRepoInfo::GetItem(const char* strID){
	if(!strID || strlen(strID) <= 0)return NULL;
	std::lock_guard<std::mutex> locker(m_mutex);
	std::map<std::string,CExchangeRepoUnit>::iterator itor = m_map.find(strID);
	if(itor == m_map.end())return NULL;
	return &(itor->second);
}

void CExchangeRepoInfo::DumpStatus(int mode)const
{

}
